<?php
include_once "conn.php";
include_once "dealFile.php";
$dir='pic/goods/';
$dir=$dir.$type.$time.'.'.$extension;
$url='http://120.77.18.178/api/pic/goods/'.$type.$time.'.'.$extension;
$uploadFile=move_uploaded_file($_FILES["file"]["tmp_name"],$dir);
// echo json_encode(['t'=>$title,'e'=>$type,'p'=>$price,'u'=>$url]);
if($uploadFile){
    $sql=$db->query("INSERT INTO goods (goods_title,goods_price,goods_type,goods_url) 
                VALUES ('$title','$price','$type','$url')");
    if($sql){
        echo json_encode(['state'=>'suc','reason'=>'null']);
    }else{
        echo json_encode(['state'=>'err','reason'=>'upload_suc,mysql_err']);
    }
}else{
    echo json_encode(['state'=>'err','reason'=>'upload_err']);
}
$db->close();
?>